﻿@{
    ViewBag.Title = "Login";
}
<header>
    <link href="../Content/bootstrap.css" rel="stylesheet">
    <script src="../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.validate.min.js" type="text/javascript"></script>

   
    <script src="../Scripts/bootstrap.min.js" type="text/javascript"></script>
     <style type="text/css">
      /* Override some defaults */
      html, body {
        background-color: #eee;
      }
      body {
        padding-top: 40px; 
      }
      .container {
        width: 300px;
      }
      .error {
          color:red; 
         }
        
      a:hover {
color: #005580;
text-decoration:none;
}
      /* The white background content wrapper */
      .container > .content {
        background-color: #fff;
        padding: 20px;
        margin: 0 -20px; 
        -webkit-border-radius: 10px 10px 10px 10px;
           -moz-border-radius: 10px 10px 10px 10px;
                border-radius: 10px 10px 10px 10px;
        -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.15);
           -moz-box-shadow: 0 1px 2px rgba(0,0,0,.15);
                box-shadow: 0 1px 2px rgba(0,0,0,.15);
      }

	  .loginForm {
		margin-left: 65px;
	  }
	
	  legend {
		margin-right: -50px;
		font-weight: bold;
	  	color: #404040;
	  }

    </style>
    <script>

        $(document).ready(function () {
            //variables
            //*********
            var subscribeForm = $('form[name="subscribe"]');
            var loginForm = $('form[name="login"]');
            var btnLogin = $('#btnLoginId'); 
            var subContainerId = $('#subContainerId');
            var loginFormDiv = $('#loginFormDivId') ;
            var showHidetime = 300;
           
            subContainerId.hide(showHidetime);
            //end of variable
            
            //loginForm 
            //**********
            $('#btnDisplaySubFormId').click(function () {
                subscribeForm.find('input').val('');
                subContainerId.show(showHidetime);
                return false;
            });

           

            btnLogin.click(function () {
                var a = $('#loginPasswordId').val() == "";
                var b = $('#loginUsernameId').val() == "";

                if ($('#loginPasswordId').val() == "" || $('#loginUsernameId').val() == "") {
                
                }
            else{
                $.ajax({
                    type: "POST",
                    url: "/Home/Login2",
                    data: loginForm.serialize(),
                    success: function (result) {
                   
                        if(result!=-1)
                        {
                            window.location.href = "/Operation/Index";
                        }
                        else
                        {
                            $('#subSuccess').html("<p stryle='colo:red;'>Identificateurs incorrects</p>");
                        }
                        
                    }

                });

        return false;
        }
            });

            //end of loginForm
            
            //subscribeForm 
            /**************/
            var subscribeForm = $('form[name="subscribe"]');
            $('#btnSubId').click(function () {
                if ($('#subLastnameId').val() == "" || $('#subFirstnameId').val() == "" || $('#subUsernameId').val() == "" || $('#subPasswordId').val() == "") {
                
                }
                else{
                $.ajax({
                    type: "POST",
                    url: "/Home/Subscribe",
                    data: subscribeForm.serialize(),
                    success: function (result) {
                        btnLogin.disabled = false;
                        subContainerId.hide(showHidetime);
                        //$('#subSuccess').html("<p style='color:#47a447'>" + result + "<img src='../Content/images/emo.jpg' style= 'max-width: 10%;'></p>");
                        $('#subSuccess').html("<p style='color:#47a447'>" + result + "!</p>");
                    }
                    
                });
        return false;
        }
            });

            //clear subForm
            /*************/
            $('#btnClearId').click(function () {

                window.location.reload(true); 
                //subscribeForm.find('input').val('');
                //subContainerId.hide(showHidetime);

                 return false;
            });
          

        }); // end ready
           
        
    </script>
</header>
<body>
    <a id="op" href="Operation/Index" hidden><a>
   <div class="container">
    <div class="content">
      <div class="row">
        @*<div class="login-form">*@
        <div id="loginFormDivId" class="loginForm">
          <h2>Connexion</h2>
          <form  name="login" method="POST" action="Home/Login2">
              <fieldset class="form-group">
                  <div class="clearfix">
                      <input type="text" id="loginUsernameId" placeholder="Nom d'utilisateur" name="username" class="form-control" required="require">
                  </div>
                  <div class="clearfix">
                      <input type="password" id="loginPasswordId" placeholder="Mot de passe" name="password" class="form-control" required="require">
                  </div>
                  <button id="btnLoginId" class="btn btn-primary">Se connecter</button>
                  <button id="btnDisplaySubFormId" class="btn btn-warning" style="float: right; margin-right: 35px">S'inscrire</button>

              </fieldset>
          </form>
            <div id="subSuccess">

            </div>
        </div>
      </div>
      
    </div><br />
       <div id="subContainerId" class="content" hidden="hidden">
           <div class="row">
               <div class="loginForm">
                   <h2>Inscription</h2>
                   <form name="subscribe">
                       <fieldset class="form-group">
                           <div class="clearfix">
                               <input type="text" id="subLastnameId" placeholder="Nom" name="lastname" class="form-control" required="require">
                           </div>
                           <div class="clearfix">
                               <input type="text" id="subFirstnameId" placeholder="Prénom" name="firstname" class="form-control" required="require">
                           </div>
                           <div class="clearfix">
                               <input type="text" id="subUsernameId" placeholder="Nom d'utilisateur" name="username" class="form-control" required="require">
                           </div>
                           <div class="clearfix">
                               <input type="password" id="subPasswordId" placeholder="Mot de passe" name="password" class="form-control" required="require">
                           </div>
                            <div class="clearfix">
                            <select class="span2" name="engineering">
                                <option>Génie civil</option>
                                <option>Génie informatique</option>
                                <option>Génie logiciel</option>
                                <option>Génie mécanique</option>
                            </select>
                        </div>
                        <div class="clearfix">
                           <button id="btnSubId" class="btn btn-success">S'insrire</button>
                           <button id="btnClearId" class="btn btn-default" style="float: right; margin-right: 35px" onclick="myFunction()">Retour</button>
                       </fieldset>
                   </form>
               </div>
       </div>

   </div>
    </div>
    <!-- /container -->
     

</body>



